// ********************************************************************************************
// Este archivo fuente es propiedad de Feria de Remates S.R.L. de C.V. Prohibida su copia o uso
// sin autorización explícita.
// This source file is propietary to Feria de Remates S.R.L. de C.V. May not be used or copied
// without explicit authorization.
// ********************************************************************************************/
package com.feriaderemates.dao.listing;

import com.feriaderemates.domain.listing.Listing;
import com.feriaderemates.domain.listing.ListingQuestion;
import com.feriaderemates.domain.listing.ListingShippingCarrier;
import com.feriaderemates.domain.listing.ListingStatus;
import com.feriaderemates.domain.listing.WatchedListing;
import java.util.List;

/**
 *
 * @author Oscar Garcia
 */
public interface ListingDaoInterface {

    /**
     * Adds parent table fields and returns the autogenerated primary key.
     * It'll add all the fields in the Listing class except:
     * number_of_views and listing_id
     *
     * @param listing the listing to add
     * @return the listing id after the insertion
     */
    public long addParentListing(Listing listing);

    /**
     * Updates parent table fields. Updatable fields have a comment in the 
     * Listing class
     *
     * @param listing the listing to update
     */
    public void updateParentListing(Listing listing);

    /**
     * Adds a Listing Question. Insert all the fields in ListingQuestion  bean
     * excepts the date for which it will be used the NOW() postgres function
     *
     * @return the new question identifier
     */
    public long addListingQuestion(ListingQuestion listing);

    /**
     * Gets the Listing questions
     *
     * @param listingId the listing id
     * @return the list of question
     */
    public List<ListingQuestion> getQuestionsByListingId(long listingId);

    /**
     * Updates a shipping carrier
     *
     * @param shippingCarriers the shipping carriers to update
     */
    public void updateListingShippingCarriers(List<ListingShippingCarrier> carriers);

    /**
     * Adds a shipping carrier into the many to many table
     *
     * @param shippingCarriers the shipping carriers to add
     */
    public void addListingShippingCarriers(List<ListingShippingCarrier> carriers);

    /**
     * Adds to the many to many table the given ids
     *
     * @param listingId the listing id
     * @param userId the userId
     */
    public void addListingToWatch(long listingId, int userId);

    /**
     * Gets the user's watch listing list
     *
     * @param userId the userId
     * @return the watch list
     */
    public List<WatchedListing> getUserWatchedListing(int userId);

    /**
     * Deletes a listing from the user's watch list
     *
     * @param listingId the listing id
     */
    public void deleteUserWatchedListing(int listingId);

    /**
     * Gets a list of active listing summary. Fields to select are: Title, end
     * date, numberOfViews, listingStatus, saleType, numberOfBids in case it's
     * an auction
     *
     * @param userId the user id
     * @return the listings
     */
    public List<Listing> getActiveListingsSummaryByUserId(int userId);

    /**
     * Updates a listing number of views
     *
     * @param listingId the listingId
     */
    public void sumOneViewToListing(long listingId);

    /**
     * Updates a listing with the given status
     *
     * @param listingId the listing id
     * @param status the new listing status
     */
    public void updateListingStatus(long listingId, ListingStatus status);
}
